"source ~/.vim/gentoo.vim
" General Configuration
set nocompatible  " Use the vim's keyboard setting, not vi
filetype plugin indent on
set ruler  " show the ruler
set laststatus=-1  " Always display the status line
set showmode  " display the current mode
set showcmd  " show command in bottom bar
set number  " show line numbers
"set relativenumber
"set cursorline  " highlight current line
"set cursorcolumn

" Enable autocompletion:
set wildmode=longest,list,full
set wildmenu  " visual autocomplete for command menu
set autoread  " Set to auto read when a file is changed from the outside
set viminfo='19,\"500
set clipboard=unnamedplus

" Tab and Indent
set tabstop=2  " number of visual spaces per TAB
set softtabstop=4  " number of spaces in tab when editing
set shiftwidth=4
set expandtab  " Expand tabs to spaces
set backspace=indent,eol,start
set autoindent  "Copy indent from last line when starting new line
set cindent

" Display tab and trail space
"set list
"set listchars=tab:>-,trail:-

" Search and Match
set hlsearch  " highlight matches
set incsearch  "real-time search
set ignorecase
set smartcase
set showmatch  " highlight matching [{()}]

" Colors, Fonts, and Syntax.
syntax enable
set t_Co=256
set encoding=utf-8
highlight Comment cterm=italic
" colors-solarized
"set background=dark
"colorscheme solarized
"call togglebg#map("<F5>")

" {{{ Autocommands
if has("autocmd")
  " When editing a file, always jump to the last cursor position
  autocmd BufReadPost *
        \ if ! exists("g:leave_my_cursor_position_alone") |
        \     if line("'\"") > 0 && line ("'\"") <= line("$") |
        \         exe "normal g'\"" |
        \     endif |
        \ endif
endif " has("autocmd")
" }}}"

" Airline.
let g:airline_theme ='solarized'
let g:airline_solarized_bg ='dark'
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#buffer_nr_show = 1
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#whitespace#enabled = 1
let g:airline#extensions#hunks#non_zero_only = 1

" Sudo permission.
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap W w !sudo tee % > /dev/null
"cmap w!! w !sudo tee % > /dev/null

"sdvc{{{
"use sdcv instead man
set keywordprg=sdcv\ -u\ 朗道英汉字典5.0
" F key call sdcv 
function! Mydict()
    let retstr=system('sdcv '.expand("<cword>"))
    windo if expand("%")=="dict-win" |q!|endif
    30vsp dict-win
    setlocal buftype=nofile bufhidden=hide noswapfile
    1s/^/\=retstr/
    1
endfunction
nnoremap F :call Mydict()<CR>
"}}}
